package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.mapper.StrategyCatalogMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyCatalogQueryObject;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StrategyCatalogServiceImpl implements IStrategyCatalogService {
    @Autowired
    private StrategyCatalogMapper strategyCatalogMapper;

    public PageInfo queryForList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(strategyCatalogMapper.queryForList(qo));
    }

    public void update(StrategyCatalog strategyCatalog) {
        strategyCatalogMapper.updateByPrimaryKey(strategyCatalog);
    }

    public void save(StrategyCatalog strategyCatalog) {
        strategyCatalogMapper.insert(strategyCatalog);
    }

    public List<StrategyCatalog> listByStrategyId(Long id) {
        StrategyCatalogQueryObject qo = new StrategyCatalogQueryObject();
        qo.setStrategyId(id);
        return strategyCatalogMapper.queryForList(qo);
    }
}
